import 'package:flutter/material.dart';
import 'MeiShiTabBarView.dart';

const List<Tab> tabs = <Tab>[
  Tab(text: '美食'),
  Tab(text: '食品'),
  Tab(text: '日用'),
  Tab(text: '花植'),
  Tab(text: '保健'),
];

class Phase01 extends StatelessWidget {
  const Phase01({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      initialIndex: 0,
      length: tabs.length,
      child: Scaffold(
        appBar: AppBar(
          bottom: TabBar(
            tabs: tabs,
            isScrollable: true
          )
        ),
        body: TabBarView(
          children: tabs.map((Tab tab) {
            return tab.text == "美食"?
              MeiShiTabBarView01() :
              Center(
                child: Text("您正在访问: ${tab.text} 页面"),
              );
          }).toList(),
        )
      ),
    );
  }
}

class Phase02 extends StatelessWidget {
  const Phase02({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      initialIndex: 0,
      length: tabs.length,
      child: Scaffold(
          appBar: AppBar(
              bottom: TabBar(
                  tabs: tabs,
                  isScrollable: true
              )
          ),
          body: TabBarView(
            children: tabs.map((Tab tab) {
              return tab.text == "美食"?
              MeiShiTabBarView02() :
              Center(
                child: Text("您正在访问: ${tab.text} 页面"),
              );
            }).toList(),
          )
      ),
    );
  }
}